/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.gatech.ealf;

import com.sun.speech.freetts.FreeTTSSpeakableImpl;

import edu.gatech.ealf.ttsplaf.TextToSpeechLookAndFeel;
/**
 *
 * @author hemanthpai
 */
public class TextToSpeechManager implements Runnable{
    
    private String speechText = null;
    
    public static boolean started;
    FreeTTSSpeakableImpl speakable;
    
    public TextToSpeechManager(String speechText){
        this.speechText = speechText;
    }
    
    @SuppressWarnings("static-access")
    public void run(){
        if(this.speechText != null && this.speechText != ""){
            this.started = true;
            speakable = new FreeTTSSpeakableImpl(this.speechText);
            try{
                TextToSpeechLookAndFeel.voice.speak(speakable);
            } catch(NullPointerException ex2){
            	
                
            } catch(Exception ex){
                
            }
        }
        this.started = false;
    }
    
    public void cancel(){
    	if(speakable != null){
                speakable.cancelled();

    	}
    }
}
